using System;
using System.Xml;
using System.Web;


namespace umlungu.engineX.webX {
	/// <summary>
	/// umlungu engineX web framework, xxx class.
	/// </summary>
	public class sessionX
	{
		/// <summary>
		/// Local objects and properties
		/// </summary>
		private System.Web.UI.Page page;
		private bool debug;
		
		/// <summary>
		/// Public properties
		/// </summary>
		
		#region Public methods
		/// <summary>Constructor</summary>
		public sessionX(System.Web.UI.Page thispage, bool wantdebug) {
			page = thispage;
			debug = wantdebug;
		}
		/// <summary>
		/// Method description
		/// </summary>
		public string Get(string thisvar) {
			return((string) page.Session[thisvar]);
		}
		/// <summary>
		/// Method description
		/// </summary>
		public void Set(string linkstr, string section, string subsect, string process, string procpage) {
			setPage(linkstr, section, subsect, process, procpage);
		}
		/// <summary>
		/// Method description
		/// </summary>
		public void SetPage(string section, string subsect, string process, string procpage) {
			setXml(false);
			setPage(section, subsect, process, procpage);
		}
		/// <summary>
		/// Method description
		/// </summary>
		public void SetXml() {
			setXml(false);
		}
		public void SetXml(string servname, string procname, XmlDocument xml) {
			setXml(servname, procname, true, null, xml);
		}
		public void SetXml(string servname, string procname, string xml) {
			setXml(servname, procname, true, xml, null);
		}
		/// <summary>
		/// Method description
		/// </summary>
		public void SetLink() {
			page.Session["x_link_prev"] = page.Session["x_link_curr"];
		}
		public void SetLink(string linkref) {
			page.Session["x_link_curr"] = linkref;
		}
		#endregion

		#region Protected methods
		#endregion

		#region Private methods
		/// <summary>
		/// Method description
		/// </summary>
		public void setPage(string linkstr, string section, string subsect, string process, string procpage) {
			page.Session["x_linkstr"] = linkstr;
			setPage(section, subsect, process, procpage);
		}
		public void setPage(string section, string subsect, string process, string procpage) {
			page.Session["x_secstr"] = section;
			page.Session["x_substr"] = subsect;
			page.Session["x_prcstr"] = process;
			page.Session["x_pgestr"] = procpage;
		}
		/// <summary>
		/// Method description
		/// </summary>
		public void setHtml(bool required) {
			setHtml(null, null, required, null, null);
		}
		public void setHtml(string servname, string procname, bool required, string contxml, XmlDocument xml) {
			page.Session["x_html_req"] = required;
			page.Session["x_serv_req"] = false;
			setXml(servname, procname, contxml, xml);
		}
		/// <summary>
		/// Method description
		/// </summary>
		public void setXml(bool required) {
			setXml(null, null, required, null, null);
		}
		public void setXml(string servname, string procname, bool required, string contxml, XmlDocument xml) {
			page.Session["x_serv_req"] = required;
			page.Session["x_html_req"] = false;
			setXml(servname, procname, contxml, xml);
		}
		public void setXml(string servname, string procname, string contxml, XmlDocument xml) {
			page.Session["x_service"] = servname;
			page.Session["x_process"] = procname;
			page.Session["x_contxml"] = contxml;
			page.Session["x_xml"] = xml;
		}
		#endregion
	}
}
		
